﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WXYW.BLL;
using WXYW.DAL;

namespace WXYW
{
    public partial class ViewApplicationDetailNeedSend : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                BindApplicationForm();
            }
        }

        private void BindApplicationForm()
        {
            ApplicationService service = new ApplicationService();
            ApplicationForm form = service.GetApplicationFormDetailByID(long.Parse(Request.QueryString[Constants.QUERYSTR_APPLICATION_ID]));
            RMACodeLabel.Text = form.ApplicationCode;
            runningNumberLabel.Text = form.RunningNumber;
            companyLabel.Text = form.User.FullName;
            receiveTimeLabel.Text = form.ReceiveDateTime != null ? Convert.ToDateTime(form.ReceiveDateTime).ToString("yyyy-MM-dd") : "";
            addressLabel.Text = form.User.UserAddress;
            contactLabel.Text = form.User.ContactPerson;
            faxLabel.Text = form.User.UserFax;
            phoneNumberLabel.Text = form.User.UserPhone;
            emailLabel.Text = form.User.UserEmail;
            ApplicationProductService Productservice = new ApplicationProductService();
            List<ApplicationProduct> products = Productservice.GetProductShouldSend(long.Parse(Request.QueryString[Constants.QUERYSTR_APPLICATION_ID]), ContextService.CurrentAccount.UserID);
            productGridView.DataSource = products;
            productGridView.DataBind();
        }

        protected void productGridView_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.DataItem != null)
            {
                e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#FFFF99'");
                e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");
                ((Label)e.Row.FindControl("IDLbl")).Text = (e.Row.RowIndex + 1).ToString();
            }
        }
    }
}
